﻿Public Class frmSuaChiTietLopHoc

    Public MaLop As Integer
    Public MaKhoi As Integer = -1
    Private Sub frmSuaChiTietLopHoc_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ds As New List(Of LopDTO)
        Dim hsBUS As New LopBUS()
        ds = LopBUS.SelectAll()

        cboKhoi.DataSource = ds
        cboKhoi.ValueMember = "MAKHOI"
        cboKhoi.DisplayMember = "TENKHOI"

        If MaKhoi > -1 Then
            cboKhoi.SelectedValue = MaKhoi
        End If
    End Sub

    Private Sub btnSua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSua.Click
        Dim lopDTO As New LopDTO()
        'Dim hsDTO = New HocSinhDTO
        lopDTO.MALOP = MaLop
        lopDTO.TENLOP = txtTenLop.Text
        lopDTO.SISO = txtSiSo.Text
        lopDTO.KHOI = txtTenKhoi.Text
        lopDTO.NAM = txtNam.Text
        lopDTO.MAKHOI = cboKhoi.SelectedValue

        Dim lopBUS As New LopBUS()
        Dim res = lopBUS.SuaLopHoc(lopDTO)
        If res >= 0 Then
            MessageBox.Show("Sửa thành công")
        Else
            MessageBox.Show("Sửa thất bại")
        End If
    End Sub

    Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
        txtMaLop.Text = String.Empty
        txtTenLop.Text = String.Empty
        txtSiSo.Text = String.Empty
        txtTenKhoi.Text = String.Empty
        txtNam.Text = String.Empty
        cboKhoi.Text = String.Empty
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub
End Class